package test;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Description
 * @Author Firenut
 * @Date 2023-09-04 14:28
 */
public class Dog {
    int count = 0;
    private static Object obj = new Object();
    public void getFood(AtomicInteger xianchang) {
        synchronized (obj) {
            if (xianchang.get() > 0) {
                xianchang.decrementAndGet();
                count++;
            }
        }
    }
}
